<template>
  <div class="my-2">
    <el-breadcrumb :separator-icon="ArrowRight">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item v-for="(item,index) in data.crumbList" :key="index">{{ item }}</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script setup>
import { reactive,watchEffect } from 'vue'
import { useRoute } from "vue-router"
import { ArrowRight} from '@element-plus/icons-vue'
const route = useRoute()
const data = reactive({
  crumbList:[]
})

watchEffect(()=>{
  let list = route.matched
  list.forEach(item => {
    if(!data.crumbList.includes(item.meta.title)){
      data.crumbList.push(item.meta.title)
    }
  })
})
</script>

<style scoped>
</style>